Skip to content

Conversation

skyamgarp
Copy link
Contributor

@skyamgarp skyamgarp commented Mar 5, 2025

With this PR trying to use powershell commands for group_list and user_list methods for windows as wmic is deprecated with windows 2025.

Copy link

codecov bot commented Mar 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.34%. Comparing base (8199309) to head (09e6328).
Report is 7 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1907      +/-   ##
==========================================
+ Coverage   74.26%   74.34%   +0.08%     
==========================================
  Files          79       79              
  Lines        4395     4409      +14     
==========================================
+ Hits         3264     3278      +14     
  Misses       1131     1131              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@skyamgarp skyamgarp marked this pull request as draft March 6, 2025 16:43
@skyamgarp skyamgarp marked this pull request as ready for review March 6, 2025 17:08
@bastelfreak
Copy link
Member

@skyamgarp thanks for the PR. I'm not really a windows person. Is that a breaking change / does it drop support for specifc older windows versions?

@skyamgarp
Copy link
Contributor Author

@skyamgarp thanks for the PR. I'm not really a windows person. Is that a breaking change / does it drop support for specifc older windows versions?

@bastelfreak I believe it is not available by default beginning windows 2025. https://learn.microsoft.com/en-us/windows-server/get-started/removed-deprecated-features-windows-server

@skyamgarp skyamgarp force-pushed the use-powershell branch 3 times, most recently from 940089c to 7821028 Compare March 13, 2025 16:48
@skyamgarp skyamgarp marked this pull request as draft March 13, 2025 17:16

# using powershell commands as wmic is deprecated in windows 2025
def group_list_using_powershell
result = exec(powershell('"Get-LocalGroup | Select-Object -ExpandProperty Name"'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't used powershell in a decade, so maybe a stupid question: Do we need double quotes within the single quotes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we need to pass this command as string instead of command hence have added quotes.

result = exec(powershell('"Get-LocalGroup | Select-Object -ExpandProperty Name"'))
groups = []
result.stdout.each_line do |line|
groups << line.strip or next
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strip or next neat 👍

@skyamgarp skyamgarp force-pushed the use-powershell branch 5 times, most recently from 2e5043f to c0df462 Compare March 17, 2025 17:19
@skyamgarp skyamgarp marked this pull request as ready for review March 17, 2025 17:22
Copy link
Contributor

@joshcooper joshcooper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we called powershell.exe -NonInteractive ... then I wonder if we could drop the echo "" | ? But it looks the echo pattern is used elsewhere, so at least we're consistent.

@skyamgarp
Copy link
Contributor Author

@bastelfreak , can you please review and merge the PR? Thanks.

@bastelfreak
Copy link
Member

I'm still not quite sure if this is a breaking change or not?

@skyamgarp
Copy link
Contributor Author

skyamgarp commented Mar 18, 2025

I'm still not quite sure if this is a breaking change or not?

I did not understand the question, as wmic is deprecated in windows 2025 we get error like 'WMIC' is not recognized as an internal or external command

Updated comment

Fixed rubocop

Add specs for new methods using powershell for user and group

Fixed rubocop failures

Using powershell DSL

Fix rubocop

Remove group_list method from pswindows

Including DSL::Wrappers inside method

Use powershell commands instead of powershell DSL

Remove unnecessary changes
@joshcooper
Copy link
Contributor

I'm still not quite sure if this is a breaking change or not?

This PR is purely additive (because we backed out the including the DSL wrapper), so should not be breaking.

@skyamgarp
Copy link
Contributor Author

@bastelfreak ,are there any more concerns?

@bastelfreak bastelfreak merged commit 3e9d54b into voxpupuli:master Mar 21, 2025
7 checks passed
@skyamgarp
Copy link
Contributor Author

@bastelfreak could you please release this change?

@skyamgarp skyamgarp deleted the use-powershell branch March 24, 2025 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants